= form_for(@article) do |f|
  - if @article.errors.any?
    #error_explanation
      %h2
        = pluralize(@article.errors.count, "error")
        prohibited this article from being saved:

      %ul
        - @article.errors.full_messages.each do |message|
          %li
            = message

  .field
    -#= f.label :title
    %label{for: "article_title"} 文章标题
    %br
    = f.text_field :title, class: "form-control"
  .field
    -#= f.label :content
    %label{for: "article_content"} 文章正文
    %br
    = f.text_area :content
  .field
    %br
    %button.submit-article.btn.btn-primary{tyle:'submit'} 发表文章
    %br

-#%div{style:"width:100%;"}
  %script#container{name:"content", type:"text/plain", style:"width:98%;"}
    写文章
  %br/


= javascript_include_tag 'http://cdn.bootcss.com/ckeditor/4.5.4/ckeditor.js'

:javascript
  CKEDITOR.replace( 'article_content' );

-#
  = stylesheet_link_tag "//ueditor.baidu.com/umeditor/themes/default/css/umeditor.min.css"
  = javascript_include_tag "//ueditor.baidu.com/umeditor/umeditor.min.js"
  = javascript_include_tag "//ueditor.baidu.com/umeditor/umeditor.config.js"
  = javascript_include_tag "//ueditor.baidu.com/umeditor/lang/zh-cn/zh-cn.js"
  = javascript_include_tag "//ueditor.baidu.com/umeditor/dialogs/link/link.js"
  = javascript_include_tag "//ueditor.baidu.com/umeditor/dialogs/image/image.js"
  = javascript_include_tag "//ueditor.baidu.com/umeditor/dialogs/video/video.js"
  = javascript_include_tag "//ueditor.baidu.com/umeditor/dialogs/map/map.js"
  = javascript_include_tag "//ueditor.baidu.com/umeditor/dialogs/formula/formula.js"
  = javascript_include_tag "//ueditor.baidu.com/umeditor/dialogs/emotion/emotion.js"



  :javascript
    var um = UM.getEditor('container', {
      autoHeight: false
    });

    um.ready(function() {
      um.setHeight(400);
    });

    $(".submit-article").click(function(){
      um.ready(function() {
        //获取html内容，返回: <p>hello</p>
        var html = um.getContent();
        $("#article_content").val(html);
      });
      $("#new_article,.edit_article").submit();
    });
  - if @article.content
    :javascript
      um.ready(function() {
        #{
          "um.setContent(\"#{@article.str_safe }\")"
        }
      });
